package com.autonomous_printer.config;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport;

@Configuration
public class FileConfig extends WebMvcConfigurationSupport {


    @Value("${file.staticAccessPath}")
    private String staticAccessPath;
    @Value("${file.uploadFolder}")
    private String uploadFolder;

    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        //staticAccessPath：/static/**
        //"file:" + uploadFolder：/media/peter/Data/dev/bisonSpace/bison-web-service/bison-service-product/target/static/
        //如果是Windows环境的话 file:=改为=》file:///
        registry.addResourceHandler(staticAccessPath).addResourceLocations("file:///" + uploadFolder);
        super.addResourceHandlers(registry);
    }

}
